﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace OF.Lib.DataAccess.Core
{
    public static class GlobalDefine
    {
        public static string ConfigurationPath
        {
            get
            {
                string folderPath = "";
                string dbConfig = System.Configuration.ConfigurationManager.AppSettings["DBConfigFolder"];
                if(string.IsNullOrWhiteSpace(dbConfig))
                {
                    folderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Configuration\DB");
                }
                else
                {
                    if(dbConfig.Contains(@":\"))
                    {
                        folderPath = dbConfig;
                    }
                    else
                    {
                        folderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dbConfig);
                    }
                }

                if(!Directory.Exists(folderPath))
                {
                    throw new Exception(string.Format("Not found DBConfigFolder:{0} ", folderPath));
                }

                return folderPath;
            }
        }
    }
}
